//
//  BaseViewController.m
//  MyMovie
//
//  Created by lanou3g on 15/9/17.
//  Copyright (c) 2015年 HeQiangQiang. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    HotReleasedViewController *hotReleasedVC = [[HotReleasedViewController alloc] init];
    [self setWitChileVC:hotReleasedVC titleName:@"热映中" imageName:@"hotreleased"];
    WillReleasedViewController *willReleasedVC = [[WillReleasedViewController alloc] init];
    [self setWitChileVC:willReleasedVC titleName:@"即将上映" imageName:@"willreleased"];
    CinemaViewController *cinemaVC = [[CinemaViewController alloc] init];
    [self setWitChileVC:cinemaVC titleName:@"电影院" imageName:@"cinema"];
//    MyViewController *myVC = [[MyViewController alloc] init];
//    [self setWitChileVC:myVC titleName:@"我的" imageName:@"user"];
}

- (void)setWitChileVC:(UIViewController *)childVC titleName:(NSString *)titleName imageName:(NSString *)imageName
{
    // 设置文本
    childVC.navigationItem.title = titleName;
    // 设置默认图标
    childVC.tabBarItem.image = [UIImage imageNamed:imageName];
    // 设置选中图标
    childVC.tabBarItem.selectedImage = [UIImage imageNamed:imageName];

    UINavigationController *childNavC = [[UINavigationController alloc] initWithRootViewController:childVC];
//    childNavC.navigationBar.barTintColor = [UIColor whiteColor];
    childNavC.navigationBar.titleTextAttributes = [NSDictionary dictionaryWithObject:[UIColor blackColor] forKey:NSForegroundColorAttributeName];
    
    childNavC.tabBarItem.title = titleName;
    if ([titleName isEqual:@"热映中"]) {
        MyViewController *myVC = [[MyViewController alloc] init];
        RESideMenu *sideMenuViewController = [[RESideMenu alloc] initWithContentViewController:childNavC leftMenuViewController:myVC rightMenuViewController:nil];
        sideMenuViewController.menuPreferredStatusBarStyle = 1; // UIStatusBarStyleLightContent
        sideMenuViewController.delegate = self;
        sideMenuViewController.contentViewShadowColor = [UIColor blackColor];
        sideMenuViewController.contentViewShadowOffset = CGSizeMake(0, 0);
        sideMenuViewController.contentViewShadowOpacity = 0.6;
        sideMenuViewController.contentViewShadowRadius = 12;
        sideMenuViewController.contentViewShadowEnabled = YES;
        sideMenuViewController.tabBarItem.title = titleName;
        sideMenuViewController.tabBarItem.image = [UIImage imageNamed:imageName];
        [self addChildViewController:sideMenuViewController];
    } else {
        // 将我们设置好的视图控制器添加到TabBarController
        [self addChildViewController:childNavC];
    }
  
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
